<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>技术器</title>
</head>
<body>

    <button class="counter">0</button>
    <button class="add">+</button>
    <button class="sub">-</button>

    <script>
        
        var counterEl = document.querySelector(".counter");
        var addEl = document.querySelector(".add");
        var subEl = document.querySelector(".sub");
        
        var counter = 0;
        
        addEl.onclick = function()
        {
            counter++;
            counterEl.textContent = counter;
        }

        subEl.onclick = function()
        {
            counter--;
            counterEl.textContent = counter;
        }

    </script>
    
</body>
</html>